Charles Peterson
Welcome to Hoffman2 Happy Hour!
The H2HH are designed to be short interactive talks that focus on a certain aspect of HPC.
Any suggestions for upcoming workshops, email me at cpeterson@oarc.ucla.edu
This presentation can be found on our UCLA OARC’s github repo.
View slides:
PDF format: H2HH_anaconda.pdf
html format:
Easy install many python and R packages with simple conda
commands
Create isolated python/R environments for different projects
Checks and solve for possible version conflicts when installing packages
Share conda env on different systems.
$HOME/.conda
pip
for pythonCreating a new conda environment
-n
option will name your new conda envSee list of all your environments that you have created
Start (activate) your conda environment
Activating the conda env gives access to the software within the env
This version of python
and R
is installed locally in your conda env and is different from the builds of python on Hoffman2.
You can see location of python in your env and check the version.
You may be familiar with using Anaconda on your local machine.
When conda is installed, it creates a conda env named base
that you may see when running conda env list
You may see messages or online tips about running the conda init
command.
This initializes conda but is NOT NEEDED to run on Hoffman2
While this does setup conda, it will change ~/.bashrc and may cause conflicts using different versions/envs.
Loading the anaconda module will already setup conda.
You can use pip
when you are in a conda env
By default, when you install a conda env, it will install it at ~/.conda
You can change this location, esp if you are low in space at $HOME
Example: Using Pytorch to fit a polynomial function from a sin function
File: pytorch_ex.py
#!/bin/bash
#$ -cwd
#$ -j y
#$ -l h_rt=1:00:00,h_data=5G
#$ -pe shared 1
# load the anaconda module
. /u/local/Modules/default/init/modules.sh
module load anaconda3/2020.11
# Activate the 'mypytorch' conda env
conda activate mypytorch
#Running python code
python pytorch_ex.py > pytorch_ex.out
The mypytorch
conda env has already been created
Find software that is available on Anaconda’s package repo
Here, you can search for software and other packages. It will also explain what conda commands you will need in order to install them to your conda env.
You can create a conda file from a environment.yml
file
You can create a conda env with all these packages by running:
While Hoffman2 already has Anaconda installed, you may need to install Anaconda on a separate machine or another HPC resource.
Visit https://repo.anaconda.com/archive/ for all the versions of Anaconda that are available.
In this example, anaconda is install at $HOME/apps/anaconda/2021.11
Questions? Comments?
Charles Peterson
Look at for more Hoffman2 workshops at https://idre.ucla.edu/calendar
HPC